<template>
  <div class="default-main ba-table-box">
    <div class="block">
      <div class="table-block">
        <el-alert class="ba-table-alert"
                  v-if="baTable.table.remark"
                  :title="baTable.table.remark"
                  type="info"
                  show-icon />
        <!-- 表格顶部菜单 -->
        <TableHeader :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
                     :quick-search-placeholder="t('Quick search placeholder', { fields: '订单号' })">
        </TableHeader>
        <Table></Table>
      </div>
      <!-- 表单 -->
      <PopupForm />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, provide } from 'vue'
import baTableClass from '/@/utils/baTable'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'
import { baTableApi } from '/@/api/common'
import Cookies from 'js-cookie'
import { useI18n } from 'vue-i18n'
import { defaultOptButtons } from '/@/components/table'
import { useAdminInfo } from '/@/stores/adminInfo'

defineOptions({
    name: 'expertReport/expertShowcase',
})
const { t } = useI18n()
const adminInfo = useAdminInfo()
const state: {
    buttonLoading: boolean
} = reactive({
    buttonLoading: false
})
const optButtons = defaultOptButtons(['edit', 'delete'])
optButtons[1].display = (row) => {
    return row.id != adminInfo.id
}

const baTable = new baTableClass(
    new baTableApi('/expertReport/expertShowcase/'),
    {
        column: [
            { type: 'selection', align: 'center', operator: false },
            { 
                label: '日期', 
                prop: 'createtime', 
                align: 'center', 
                render: 'datetime', 
                sortable: 'custom', 
                operator: 'RANGE', 
                width: 160 
            },
            {
                label: '店铺',
                prop: 'shop_name',
                align: 'center',
                comSearchRender: 'remoteSelect',
                remote: {
                    pk: 'id',
                    field: 'name',
                    remoteUrl: '/shop/shop/index',
                    params: { select: true },
                },
                operator: false
            },
            {   
                label: '建联人', 
                prop: 'liaison_person', 
                align: 'center',
                operator: false
            },
            {   
                label: '红人名', 
                prop: 'internet_celebrity', 
                align: 'center',
                operator: false
            },
            {   
                label: '订单数', 
                prop: 'ordernum', 
                align: 'center',
                operator: false
            },
            {   
                label: '销售额', 
                prop: 'sales', 
                align: 'center',
                operator: false
            },
            {   
                label: '支出佣金', 
                prop: 'commission_expenses', 
                align: 'center',
                operator: false
            },
            {
                label: t('Operate'),
                align: 'center',
                width: '100',
                render: 'buttons',
                buttons: optButtons,
                operator: false,
            }
        ],
        dblClickNotEditColumn: ['all']
    }
)

provide('baTable', baTable)

baTable.mount()
baTable.getIndex()

</script>

<style scoped lang="scss">
</style>
